package com.google.code.rgbgoesbetween.data;

import java.util.HashMap;
import java.util.Map;

import android.annotation.SuppressLint;
import android.util.Log;


public class InMemoryDatastore implements Datastore {
	@SuppressLint("UseSparseArrays")
	private Map<Integer, Profile> users = new HashMap<Integer, Profile>();
	private Map<String, Profile> usersByName = new HashMap<String, Profile>();
	
	
	@Override
	public Profile getAccountInfo(String username, String passHash) {
		Log.e("Requesting ", String.format("username: %s passhash: %s ", username, passHash));
		Profile requested = usersByName.get(username);
		if (requested == null) {
			return null;
		}
		if (!requested.getPassHash().equals(passHash)) {
			return null;
		}
		return requested;
	}

	@Override
	public Profile createProfile(Profile profile) {
		if(users.containsKey(profile.getId()) ) {
			return null; //We already have this one!! Fail
		}
		users.put(profile.getId(), profile);
		usersByName.put(profile.getUsername(), profile);
		return profile;
	}

	@Override
	public QueryStatus updateProfile(Profile profile) {
		return null;
	}

	@Override
	public QueryStatus createItem(Item item) {	
		return null;
	}

	@Override
	public QueryStatus updateItem(Item item) {
		return null;
	}

	@Override
	public QueryStatus deleteItem(Item item) {	
		return null;
	}

	@Override
	public Item requestItem(int id) {	
		return null;
	}

}
